﻿using CuteSprite.Eme.UI.Utils;
using HmFramework.Components;
using HmFramework.Components.Controls;
using HmFramework.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CuteSprite.Eme.UI.Settlement
{
  public partial class FrmBillingPrice : EmeEntityForm
  {

    #region -- 构造 --

    #region - 新增 -

    /// <summary>默认构造函数</summary>
    /// <param name="settlementSolutionID"></param>
    /// <param name="billingSolutionID"></param>
    /// <param name="entity"></param>
    public FrmBillingPrice(IEntity entity)
      : base(entity, false)
    {
      InitializeComponent();
      InitForm();
    }

    #endregion

    #region - 编辑 -

    /// <summary>构造函数</summary>
    /// <param name="settlementSolutionID"></param>
    /// <param name="entity">实体对象</param>
    /// <param name="readOnly">是否只读，指定编辑还是浏览实体信息</param>
    public FrmBillingPrice(IEntity entity, Boolean readOnly)
      : base(entity, readOnly)
    {
      InitializeComponent();
      InitForm();
    }

    #endregion

    #endregion

    #region -- 窗体事件 --

    #region - method InitComponent -

    ///// <summary>控件初始化</summary>
    protected override void InitComponent()
    {
      base.InitComponent();

      if (frmBusinessCategory == null) { frmBusinessCategory = FindControl("frmBusinessCategory") as ComboBoxEx; }
      if (frmGoodsCategory == null) { frmGoodsCategory = FindControl("frmGoodsCategory") as ComboBoxEx; }

      this.OnValid += new System.EventHandler<CuteSprite.Eme.UI.Utils.EntityFormEventArgs>(this.FrmBsdSettlementSolution_OnValid);
    }

    #endregion

    #region - 实体验证 -

    private void FrmBsdSettlementSolution_OnValid(object sender, EntityFormEventArgs e)
    {
      if (frmBusinessCategory != null && (Int32)frmBusinessCategory.SelectedValue <= 0)
      {
        MessageBoxEx.Show("请选择业务类别！", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        e.Cancel = true;
        return;
      }
      if (frmGoodsCategory != null && (Int32)frmGoodsCategory.SelectedValue <= 0)
      {
        MessageBoxEx.Show("请选择货物类别！", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        e.Cancel = true;
        return;
      }
      if (frmCode.Text == String.Empty)
      {
        MessageBoxEx.Show("代码不能为空,请输入代码！", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        e.Cancel = true;
        return;
      }
    }

    #endregion

    #endregion
  }
}
